/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Damian
 */
@Entity
@Table(name = "suscriptions")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Suscriptions.findAll", query = "SELECT s FROM Suscriptions s"),
    @NamedQuery(name = "Suscriptions.findByIdSuscription", query = "SELECT s FROM Suscriptions s WHERE s.suscriptionsPK.idSuscription = :idSuscription"),
    @NamedQuery(name = "Suscriptions.findByIdClient", query = "SELECT s FROM Suscriptions s WHERE s.suscriptionsPK.idClient = :idClient"),
    @NamedQuery(name = "Suscriptions.findByIdLocal", query = "SELECT s FROM Suscriptions s WHERE s.suscriptionsPK.idLocal = :idLocal")})
public class Suscriptions implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SuscriptionsPK suscriptionsPK;
    @JoinColumn(name = "ID_CLIENT", referencedColumnName = "ID_CLIENT", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Client client;
    @JoinColumn(name = "ID_LOCAL", referencedColumnName = "ID_LOCAL", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Local local;

    public Suscriptions() {
    }

    public Suscriptions(SuscriptionsPK suscriptionsPK) {
        this.suscriptionsPK = suscriptionsPK;
    }

    public Suscriptions(int idSuscription, int idClient, int idLocal) {
        this.suscriptionsPK = new SuscriptionsPK(idSuscription, idClient, idLocal);
    }

    public SuscriptionsPK getSuscriptionsPK() {
        return suscriptionsPK;
    }

    public void setSuscriptionsPK(SuscriptionsPK suscriptionsPK) {
        this.suscriptionsPK = suscriptionsPK;
    }

    public Client getClient() {
        return client;
    }

    public void setClient(Client client) {
        this.client = client;
    }

    public Local getLocal() {
        return local;
    }

    public void setLocal(Local local) {
        this.local = local;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (suscriptionsPK != null ? suscriptionsPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Suscriptions)) {
            return false;
        }
        Suscriptions other = (Suscriptions) object;
        if ((this.suscriptionsPK == null && other.suscriptionsPK != null) || (this.suscriptionsPK != null && !this.suscriptionsPK.equals(other.suscriptionsPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.Suscriptions[ suscriptionsPK=" + suscriptionsPK + " ]";
    }
    
}
